/**
 * 
 */
package cvcg.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.ForeignKey;

/**
 * @author jaracje
 *
 */
@Entity
@Table(name="VOTE")
@SuppressWarnings("serial")
public class Vote implements Serializable
{
	@Id @GeneratedValue
	@Column(name="VOTE_P")
	private Long id;
	@ManyToOne(fetch=FetchType.EAGER)
	@JoinColumn(name="PLAYER_F")
	@ForeignKey(name = "CTR_VOTE_R_PLAYER")
	private Player player;
	@ManyToOne(fetch=FetchType.EAGER)
	@JoinColumn(name="GAME_F")
	@ForeignKey(name = "CTR_VOTE_R_GAME")
	private Game game;	
	private Integer weight = Integer.valueOf(1);

	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public Player getPlayer() {
		return player;
	}
	public void setPlayer(Player player) {
		this.player = player;
	}
	public Game getGame() {
		return game;
	}
	public void setGame(Game game) {
		this.game = game;
	}		
	public Integer getWeight() {
		return weight;
	}
	public void setWeight(Integer weight) {
		this.weight = weight;
	}
	
	@Transient
	public String getGameName() 
	{
		String gameName = null;
		if (game!=null) 
		{
			gameName = game.getName();
		}
		return gameName;
	}
	
	@Transient
	public String getPlayerName() 
	{
		String playerName = null;
		if (player!=null) 
		{
			playerName = player.getName();
		}
		return playerName;
	}

	@Transient
	public Long getGameId() 
	{
		Long gameId = null;
		if (game!=null) 
		{
			gameId = game.getId();
		}
		return gameId;
	}
	
	@Transient
	public Long getPlayerId() 
	{
		Long playerId = null;
		if (player!=null) 
		{
			playerId = player.getId();
		}
		return playerId;
	}

}
